//
//  NetworkAlertView.m
//  EasyToo
//
//  Created by Jr Lan on 13-9-17.
//
//

#import "NetworkAlertView.h"

@implementation NetworkAlertView
{
    UIAlertView *baseAlert;
}

static NetworkAlertView* gView = nil;

+ (NetworkAlertView*)shareView
{
    if (gView == nil) {
        gView = [[NetworkAlertView alloc] init];
    }
    return gView;
}


//展示等待view
- (void)showNetView
{
    baseAlert = [[UIAlertView alloc] initWithTitle:@"载入中..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [baseAlert show];
    
    // Create and add the activity indicator
    UIActivityIndicatorView *aiv = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    aiv.center = CGPointMake(baseAlert.bounds.size.width / 2.0f, baseAlert.bounds.size.height - 40.0f);
    [aiv startAnimating];
    [baseAlert addSubview:aiv];
    [aiv release];
}

//展示等待view
- (void)showNetView:(NSString*) title
{
    baseAlert = [[UIAlertView alloc] initWithTitle:title message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [baseAlert show];
    
    // Create and add the activity indicator
    UIActivityIndicatorView *aiv = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    aiv.center = CGPointMake(baseAlert.bounds.size.width / 2.0f, baseAlert.bounds.size.height - 40.0f);
    [aiv startAnimating];
    [baseAlert addSubview:aiv];
    [aiv release];
}

//取消展示view
- (void)delView
{
    [baseAlert dismissWithClickedButtonIndex:0 animated:NO];
    [baseAlert release];
    baseAlert = nil;
}

@end
